/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

/**
 * <p>Project: app2022 - Dir3
 * <p>Powered by webrx On 2022-01-17 15:23:22
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Dir3 {
    public static void main(String[] args) throws IOException {
        //del("c:/abc");
        FileUtils.deleteDirectory(new File("c:/abc"));
    }

    /**
     * Description: 递归删除目录
     *
     * @date: 2022/1/17 15:33
     * @params: [java.lang.String]
     * @return: void
     */
    public static void del(String dir) {
        del(new File(dir));
    }

    /**
     * Description: 递归方法删除非空目录
     *
     * @date: 2022/1/17 15:24
     * @params: [java.io.File]
     * @return: void
     */
    public static void del(File dir) {
        if (dir.isDirectory()) {
            for (File f : dir.listFiles()) {
                if (f.isDirectory()) {
                    del(f);
                } else {
                    //删除文件，和空目录;
                    f.delete();
                }
            }
        }
        dir.delete();
    }
}
